package top.huntwolf.admin.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import top.huntwolf.admin.pojo.book.Book;
import top.huntwolf.admin.pojo.book.BuyBook;
import top.huntwolf.admin.pojo.book.SaleBook;

import java.util.List;

@Mapper
@Repository
public interface BookDao {

    /*依据isbn查询*/
    BuyBook selectBookByISBNAndReserve(String isbn);

    /*依据isbn查询*/
    BuyBook selectBookByISBN(String isbn);

    /*依据isbn查询*/
    SaleBook selectSaleBookByISBN(String isbn);

    /*依据搜索字段以销量倒序排列*/
    List<BuyBook> selectBookBySearchFieldOrderSaleDesc(String searchField);

    /*依据搜索字段以销量正序排列*/
    List<BuyBook> selectBookBySearchFieldOrderSaleAsc(String searchField);

    /*依据搜索字段以价格正序排列*/
    List<BuyBook> selectBookBySearchFieldOrderPriceDesc(String searchField);

    /*依据搜索字段以价格正序排列*/
    List<BuyBook> selectBookBySearchFieldOrderPriceAsc(String searchField);

    /*查询全部*/
    List<BuyBook> selectAll();

    /*增加一本*/
    int insert(BuyBook book);

    /*增加卖书*/
    int insertSaleBook(Book book);

    /*更新一本*/
    int update(BuyBook book);

    /*删除一本*/
    int delete(String isbn);

    /*依据二级分类以销售量降序排列*/
    List<BuyBook> selectBookBySubjectOrderSaleDesc(Integer subjectId);

    /*依据二级分类以销售量正序排列*/
    List<BuyBook> selectBookBySubjectOrderSaleAsc(Integer subjectId);

    /*依据二级分类以价格降序排列*/
    List<BuyBook> selectBookBySubjectOrderPriceDesc(Integer subjectId);

    /*依据二级分类以价格正序排列*/
    List<BuyBook> selectBookBySubjectOrderPriceAsc(Integer subjectId);

    /*依据一级分类以销售量降序排列*/
    List<BuyBook> selectBookByParentSubjectOrderSaleDesc(Integer parentSubjectId);

    /*依据一级分类以销售量正序排列*/
    List<BuyBook> selectBookByParentSubjectOrderSaleAsc(Integer parentSubjectId);

    /*依据一级分类以价格降序排列*/
    List<BuyBook> selectBookByParentSubjectOrderPriceDesc(Integer parentSubjectId);

    /*依据一级分类以价格正序排列*/
    List<BuyBook> selectBookByParentSubjectOrderPriceAsc(Integer parentSubjectId);

    /*依据创建时间以降序排列*/
    List<BuyBook> selectBookByCreateTime();

    List<BuyBook> selectBySubjectId(int subjectId);

    int IncreaseSaleVolume(BuyBook book);

    BuyBook selectBookByISBNAndStore(@Param("isbn") String isbn,@Param("storeId") Integer storeId);

    int IncreaseSearchTime(BuyBook book);
}
